﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Warehouse.Core;
using Tanmia.Basis.ViewModel;
using Tanmia.Basis.ViewInterface;
using Microsoft.Practices.Prism.Regions;
using Tanmia.Basis.Data;
using Tanmia.Warehouse.Domain;
using System.Globalization;
using Tanmia.Warehouse.Presentation.Properties;
using System.Windows.Data;

namespace Tanmia.Warehouse.Presentation.Scenarios.StoreScenario
{
    public class StoreViewModel : BaseEditAndBrowseViewModel<Store>
    {
        protected BranchDomain BranchDomain { get; set; }
        public CollectionView Branchs { get; protected set; }


        public StoreViewModel(IShellView shellView, IRegionManager regionManager, IMessageService messageService, ISessionManager sessionManager, StoreDomain storeDomain, BranchDomain branchDomain)
            : base(shellView, regionManager, messageService, sessionManager, storeDomain)
        {
            this.BranchDomain = branchDomain;

            ViewInfo = new ViewInfo("تحرير مستودع", "المستودعات تتواجد ضمن الفروع, الموزع جغرافياً.");
            BrowserInfo = new ViewInfo("إستعراض المستودعات", "");
            EntityName = "Store";

            Branchs = CollectionViewSource.GetDefaultView(branchDomain.Gets()) as CollectionView;
        }

        protected override void OnDelete()
        {
            MessageServiceResultEnum result = MessageService.RequestUserConfirmation(
                string.Format(CultureInfo.CurrentCulture, Resources.DeleteConfirmation,
                EntityName, CurrentEntity.StoreID));

            if (result == MessageServiceResultEnum.Yes)
            {
                bool deletionResult = DeleteCore();
                UpdateStatus(deletionResult, Resources.DeleteSucceed, Resources.DeleteUnsucceed);
            }
        }
    }
}
